<template>
	<view>

		<sortPickerList ref="sortPickerList" @selList="selectListed"></sortPickerList>
		
		<view style="height: 115rpx;"></view>

		<view class="bottom">
			<text @click="commit">确认选择</text>

		</view>
		
	</view>
</template>

<script>
	import sortPickerList from '@/components/sortPickerList.vue'

	export default {
		components: {
			sortPickerList
		},
		data() {
			return {
				selList: []
			}
		},
		methods: {
			selectListed(list) {
				console.log('点击了', list);
        // this.selList = this.selList.concat(list);
        this.selList = list;
			},

			commit() {
				if (uni.$u.test.isEmpty(this.selList)) {
					this.$u.toast('请选择品牌')
					return
				}

				uni.$emit('selBrand', this.selList)
				uni.navigateBack()
			}

		},
		onLoad() {
			
			let filterList = this.$store.state.params.filterCondition
			
			let that = this
			
			this.$u.api.getCarBrandInfo().then(res => {
				
				filterList.forEach(item=>{
					if('carBrand'==item.type){
						
						
						res.forEach(e=>{
							
							item.childList.forEach(citem=>{
								if(e.code==citem.code){
									e.check = citem.check
									
									if(uni.$u.test.isEmpty(e.check)){
										e.check = false
									}
									
								}
							})
						})
					}
					
				})
				


				//第一个参数为对象数组，第二个参数为要根据哪个字段名排序
				this.$refs["sortPickerList"].initPage(res, 'value')

				// this.$refs["sortPickerList"].initPage(
				// ,'value')

				// console.log('接口数据', res);
			})


		}
	}
</script>

<style lang="scss" scoped>
	.list-cell {
		display: flex;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		color: #323233;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
	}

	.bottom {
		position: fixed;
		width: 100%;
		height: 100rpx;
		bottom: 0;
		z-index: 999;
		background-color: white;
		display: flex;
		align-items: center;
		justify-content: center;

		text {
			width: 93%;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 50rpx;
			background-color: $blue15;
			color: white;
			text-align: center;
			font-size: 30rpx;
		}
	}
</style>
